import userUserStore from '@s/user.js'
export default {
  permission: {
    mounted(el, binding, vnode) {
      const { value } = binding
      if (value.length > 0 && Array.isArray(value)) {
        const user = userUserStore()

        if (user.userInfo.role && !value.includes(user.userInfo.role)) {
          el.parentNode && el.parentNode.removeChild(el)
        }
      } else {
        throw new Error(`need roles! Like v-permission="['admin','editor']"`)
      }
    },
  },
}
